#[macro_use]
extern crate lazy_static;

use crate::initialize::config::init_config;
use crate::initialize::db::init_db;
use crate::initialize::log::init_log;
use crate::initialize::micro_engine::init_engine;
use crate::initialize::service::init_service;

pub mod controller;
pub mod handlers;
pub mod initialize;
pub mod middleware;
pub static PATH: &str = "path";
pub static HEADERS: &str = "headers";
pub static BODY: &str = "body";
pub static QUERY: &str = "query";

/**
*model:http
*description:系统server聚合
*author:cassie-lxd<348040933@qq.com>
*date:2022/10/15
*/
pub mod router;
pub mod service;

///**
///*description: 启动初始化上下文
///*author:cassie-lxd<348040933@qq.com>
/// */
pub async fn init_context() {
  print_banner();
  //初始化配置
  init_config().await;
  //初始化日志
  init_log();
  //初始化db
  init_db().await;

  //初始化 所有服务
  init_service().await;
  //初始化js引擎
  init_engine().await;
}

fn print_banner() {
  let banner = r#"  _____              _        _                      _____          _
    / ____|            (_)      | |                    / ____|        | |
   | |     __ _ ___ ___ _  ___  | |     _____      __ | |     ___   __| | ___
   | |    / _` / __/ __| |/ _ \ | |    / _ \ \ /\ / / | |    / _ \ / _` |/ _ \
   | |___| (_| \__ \__ \ |  __/ | |___| (_) \ V  V /  | |___| (_) | (_| |  __/
    \_____\__,_|___/___/_|\___| |______\___/ \_/\_/    \_____\___/ \__,_|\___|
"#;
  println!("{}", banner);
}
